package com.example.rpapp.assembler;


import com.example.rpclient.dto.AwardAddCmd;
import com.example.rpclient.dto.AwardUpdateCmd;
import com.example.rpclient.dto.data.AwardVo;
import com.example.rpdomain.award.AwardEntity;
import com.example.rpdomain.award.AwardNumber;

import java.time.LocalDateTime;


public class AwardAssembler {

    public static AwardEntity toAddEntity(AwardAddCmd cmd) {
        AwardEntity awardEntity = new AwardEntity();
        awardEntity.setPrizeId(cmd.getPrizeId());
        awardEntity.setActivityId(cmd.getActivityId());
        awardEntity.setNumber(new AwardNumber(cmd.getNumber()));
        awardEntity.setAwardName(cmd.getAwardName());
        awardEntity.setProbability(cmd.getProbability());
        awardEntity.setCreateTime(LocalDateTime.now());
        awardEntity.setCreator("大帅哥");
        awardEntity.setUpdateTime(LocalDateTime.now());
        awardEntity.setUpdater("大帅哥");

        return awardEntity;
    }

    public static AwardVo toAwardVO(AwardEntity entity) {
        AwardVo awardVO = new AwardVo();
        awardVO.setId(entity.getId());
        awardVO.setActivityId(entity.getActivityId());
        awardVO.setPrizeId(entity.getPrizeId());
        awardVO.setNumber(entity.getNumber().getNumber());
        awardVO.setAwardName(entity.getAwardName());
        awardVO.setProbability(entity.getProbability());
        awardVO.setCreateTime(entity.getCreateTime());
        awardVO.setCreator(entity.getCreator());
        awardVO.setUpdateTime(entity.getUpdateTime());
        awardVO.setUpdater(entity.getUpdater());
        awardVO.setPrizeName(entity.getPrizeName());
        return awardVO;
    }

    public static AwardEntity toUpdateEntity(AwardUpdateCmd cmd) {
        AwardEntity awardEntity = new AwardEntity();
        awardEntity.setId(cmd.getId());
        awardEntity.setPrizeId(cmd.getPrizeId());
        awardEntity.setActivityId(cmd.getActivityId());
        awardEntity.setNumber(new AwardNumber(cmd.getNumber()));
        awardEntity.setAwardName(cmd.getAwardName());
        awardEntity.setProbability(cmd.getProbability());
        awardEntity.setUpdateTime(LocalDateTime.now());
        awardEntity.setUpdater("大帅哥");

        return awardEntity;
    }

    public static AwardAddCmd toAwardAddCmd(AwardVo awardVO) {
        AwardAddCmd awardAddCmd = new AwardAddCmd();
        awardAddCmd.setPrizeId(awardVO.getPrizeId());
        awardAddCmd.setNumber(awardVO.getNumber());
        awardAddCmd.setAwardName(awardVO.getAwardName());
        awardAddCmd.setProbability(awardVO.getProbability());

        return awardAddCmd;
    }

    public static AwardEntity toAwardEntity(AwardVo awardVO) {
        AwardEntity awardEntity = new AwardEntity();
        awardEntity.setId(awardVO.getId());
        awardEntity.setPrizeId(awardVO.getPrizeId());
        awardEntity.setActivityId(awardVO.getActivityId());
        awardEntity.setNumber(new AwardNumber(awardVO.getNumber()));
        awardEntity.setAwardName(awardVO.getAwardName());
        awardEntity.setProbability(awardVO.getProbability());
        awardEntity.setCreateTime(awardVO.getCreateTime());
        awardEntity.setCreator("大帅哥");
        awardEntity.setUpdateTime(awardVO.getUpdateTime());
        awardEntity.setUpdater("大帅哥");

        return awardEntity;
    }
}
